package com.mgface.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wanyuxiang
 * @version 1.0
 * @project spring-boot-oauth2-system
 * @create 2019-11-20 17:07
 **/
@Configuration
public class CustomWebMvcConfiguer implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor getLoginInterceptor() {
        return new OAuth2Interceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor interceptor = this.getLoginInterceptor();
        registry.addInterceptor(interceptor).excludePathPatterns("/oauth2/**");
    }
}
